package com.nulldev.util.web.flexibleKit.scfk.protocols;

import com.nulldev.util.manage.MarkedForRemoval;

public enum PreferredProtocol {
	/* Standard (HTTP) */

	HTTP_0_9("HTTP/0.9", 0.9),
	HTTP_1_0("HTTP/1.0", 1.0),
	HTTP_1_1("HTTP/1.1", 1.1), /* Default */

	/* Standard (non-HTTP) */

	GOPHER("GOPHER", 1.0),
	GEMINI("GEMINI", 1.0),

	/* Unsupported */

	HTTP_2_0("HTTP/2.0", 2.0),
	HTTP_3_0("HTTP/3.0", 3.0),

	/* From nullUtil 3.x */

	@Deprecated
	@MarkedForRemoval(reason = "Deprecated within nullUtil.")
	STTP_0_1("STTP/0.1", 0.1),
	STTP_0_2("STTP/0.2", 0.2),

	;

	public final String protString;
	public final double protVersion;

	private PreferredProtocol(final String ps, final double protocolVersion) {
		this.protString = ps;
		this.protVersion = protocolVersion;
	}

	public static PreferredProtocol get(final String httpVer) {
		for (final PreferredProtocol type : values()) {
			if (type.protString.equals(httpVer)) {
				return type;
			}
		}
		return null;
	}
}
